Improving web performance is not just about faster page loads. It’s about delivering a smoother, more accessible user experience across devices.
Improving web performance is not just about faster page loads. It’s about delivering a smoother, more accessible user experience across devices. Google’s Lighthouse is a widely accepted tool to benchmark that experience. This guide outlines ten actionable practices frontend developers can apply today to improve Lighthouse scores in real-world applications using React and TypeScript.
Large, unoptimised images are a common cause of poor performance scores. Convert assets to modern formats like WebP or AVIF. Use responsive images with srcset
and sizes
to serve appropriately sized versions based on screen resolution.
Example:
<img
srcSet="/img/banner-800w.webp 800w, /img/banner-1600w.webp 1600w"
sizes="(max-width: 768px) 800px, 1600px"
src="/img/banner-1600w.webp"
alt="Promotional banner"
/>
Lazy loading defers the loading of images and components not visible in the initial viewport. This improves initial load time and time to interactive.
Use native loading="lazy"
for images, and dynamic import()
in React for route-level or component-level code splitting.
const Chart = React.lazy(() => import("./Chart"))
Analyse your bundle using Webpack Bundle Analyzer. Remove unused dependencies. Prefer lighter alternatives where possible (e.g., date-fns
instead of moment.js
). Use tree-shaking and ensure dead code is eliminated by setting sideEffects: false
in package.json
.
Set proper cache headers for static assets. In Next.js, you can define headers in next.config.js
to control cache behaviour.
headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
];
}
Server-Side Rendering (SSR) adds flexibility, but static rendering (SSG) offers better performance and reliability. In Next.js, use getStaticProps
instead of getServerSideProps
when data does not change per request.
Reduce critical CSS and avoid loading large fonts or third-party scripts early. Use font-display: swap
and defer non-critical JS using async
or defer
attributes.
Monitor metrics like Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). Use the web-vitals
library or tools like SpeedCurve to track these in production.
import { getCLS, getFID, getLCP } from "web-vitals"
getCLS(console.log)
getFID(console.log)
getLCP(console.log)
Content Delivery Networks (CDNs) reduce latency by serving assets from geographically distributed servers. Tools like Vercel and Cloudflare automatically enable CDN support for frontend assets.
Third-party scripts (ads, analytics, widgets) can significantly delay rendering. Audit what is necessary. Load scripts lazily or via a tag manager with clear control over load timing.
Performance is not static. Set up continuous monitoring using Lighthouse CI or PageSpeed Insights. Incorporate performance budgets in CI pipelines to prevent regressions over time.
Performance optimisation is a moving target. By integrating these ten strategies into your development workflow, you can systematically raise your Lighthouse score, improve real-world user experiences, and ensure your frontend remains competitive. Focus on measurement, make small but consistent improvements, and treat performance as a shared responsibility across the team.